package com.yifa.health_manage.adapter;

import java.util.ArrayList;
import java.util.List;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import com.yifa.health_manage.R;
import com.yifa.health_manage.model.BloodValuesInfo;

public class GridAdapter extends BaseAdapter {

	private Context mContext;

	private List<BloodValuesInfo> gridModels = new ArrayList<BloodValuesInfo>();

	public GridAdapter(Context c) {
		mContext = c;

	}

	public void setDatas(List<BloodValuesInfo> date) {
		gridModels = date;
		this.notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return gridModels.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return gridModels.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = LayoutInflater.from(mContext).inflate(
					R.layout.item_x_grid, parent, false);
			holder.textView = (TextView) convertView
					.findViewById(R.id.textView11);

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		if (position % 9 == 0) {
			holder.textView.setText(gridModels.get(position).getDatetime());
		} else
			holder.textView.setText(gridModels.get(position).getValue());

		return convertView;
	}

	class ViewHolder {
		TextView textView;
	}

	
}
